package edu.sctu.zhuyingzhi.month201505.day20150517.homework;

import java.util.*;

/**
 * Created by user13 on 2015/5/17.
 */
public class TextMore {
    Teachers teacher = new Teachers();


    public Teacher[] sotrNumber(){

        Teacher[] teacherArray = teacher.TeacherMessage();
        Teacher[] teacherA = new Teacher[1];




        for (int i = 0; i < (teacherArray.length-1); i++) {

            for (int j = 0; j < (teacherArray.length-1); j++) {
                if (teacherArray[j].getNumber() > teacherArray[j+1].getNumber()){


                    teacherA[0] = teacherArray[j];
                    teacherArray[j] = teacherArray[j+1];
                    teacherArray[j+1] =teacherA[0];


                }

            }
        }
        return teacherArray;
    }

    public Teacher[] sortStudent(){
        Teacher[] teacherArray1 = teacher.TeacherMessage();
        Teacher[] teacherA = new Teacher[1];


        for (int i = 0; i < (teacherArray1.length-1); i++) {

            for (int j = 0; j < (teacherArray1[i].getStudent().length-1); j++) {

                if (teacherArray1[i].getStudent()[j].getGradle()>teacherArray1[i+1].getStudent()[j+1].getGradle()){

                    teacherA[0] = teacherArray1[j];
                    teacherArray1[j] = teacherArray1[j+1];
                    teacherArray1[j+1] =teacherA[0];

                }
            }
        }
        return teacherArray1;
    }

    public List<Teacher> pritCoded(){
        Teacher[] teacherArray2 = teacher.TeacherMessage();
        List<Teacher> list= new ArrayList<>();
        for (int i = 0; i < teacherArray2.length; i++) {
            if (teacherArray2[i].getTitle().equals("教授"))
                list.add(teacherArray2[i]);
        }
        return list;
    }
}
